package com.jingdong.dao.productType.impl;

import com.jingdong.dao.productType.ProductTypeOneDao;
import com.jingdong.model.Product_type_one;
import com.jingdong.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ProductTypeOneDaoImpl implements ProductTypeOneDao {
    @Override
    public List<Product_type_one> oneTypeList() {
        try{
            SqlSession sqlSession= MyBatisUtils.getSqlSession();
            List<Product_type_one> oneTypeList=sqlSession.selectList("com.jingdong.productOneTypeModel.list");
            sqlSession.close();
            return oneTypeList;
        }catch ( Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Product_type_one getById(Long id) {
        try{
            SqlSession sqlSession= MyBatisUtils.getSqlSession();
            Product_type_one product_type_one=sqlSession.selectOne("com.jingdong.productOneTypeModel.getById",id);
            sqlSession.close();
            return product_type_one;
        }catch ( Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
